package com.wanxi.array;

import java.util.Scanner;

/**
 * 键盘录入数组
 */
public class ScannerArrayMax {
    public static void main(String[] args) {
//        int[] arr = {0, 0, 0, 0, 0};
        int[] arr = new int[5];
        Scanner scanner = new Scanner(System.in);
        for (int i = 1; i <= arr.length; i++) {
            System.out.println("请输入第" + i + "个数");
            arr[i - 1] = scanner.nextInt();
        }
        System.out.println("现在的数组的值为：");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + ",");
        }
        System.out.println("");
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
            }
        }
        System.out.println("数组的最大值为:" + max);
    }
}
